﻿@{
    ViewBag.Title = "主页";
}
@using VCommons;
@using EntityFrameworks.Web.Core.Helper;
@using EntityFrameworks.Web.Core.Models;
@model  List<EntityTest.WebManageUsers>
<div>新窗口返回:<input type="text" id="newValue" /></div>
<a href="/home/newWin" target="_blank">亲窗口</a>
<h2>@ViewBag.Message</h2>
@foreach (var item in Model)
{ 
    <p>@item.RealName</p>
}
@using (Html.BeginForm())
{
    <p>@Html.Raw(ViewBag.info)</p>
    <p>下单流程：写库＝》发邮件确认＝》写用户动态</p>
    <p>订单描述：<input type="text" name="title" /></p>
    <p>用户邮箱：<input type="text" name="email" /></p>
    <button>下订单</button>
}

<ul data-bind="template:{name:'contactsList',foreach:list0}">
</ul>
<ul data-bind="template:{name:'contactsList',foreach:list1}">
</ul>


<script id="contactsList" type="text/html">
    <li>
        <ul>
            <li>Name: <span data-bind="text:Name"></span></li>
            <li>Phone No:<span data-bind="text:PhoneNo"></span></li>
            <li>Email Address:<span data-bind="text:EmailAddress"></span></li>
        </ul>
    </li>
</script>
<div id="list"></div>
<script type="text/javascript">
    $.ajax({
        url: '@Url.Action("SelectlistForTree")',
        type: 'GET',
        data: { selID: 3 },
        success: function (msg) {
            $("#list").append(msg);
        }
    });

    function treeOnSelect(obj) {
        var res = '';
        $.ajax({
            url: '@Url.Action("GetSubTree")',
            type: 'GET',
            data: { parentId: obj.value },
            success: function (msg) {
                $(obj).nextAll().remove();
                res = "<select name='Sub' onchange='treeOnSelect(this)' > ";
                res += "<option value=''>请选择</option>";
                $.each(msg, function (i, item) {
                    res += "<option value='" + item["ID"] + "'>" + item["Name"] + "</option>";
                });
                res += "</select>";
                if ($(res).find("option").size() > 1)
                    $(obj).after(res);
            }
        });
    }

    $.ajax({
        Type: "GET",
        url: "http://localhost:7543/api/Values",
        dataType: "jsonp",//json,同域与跨域的后台代码是一样的，不需要重新封装JsonpMediaTypeFormatter
        //  onerror: function () { alert("error") },//jsonp不支持它们
        // beforeSend: function () { alert("beforeSend error") },//jsonp不支持它们
        success: function (data0) {
            ko.applyBindings({
                list0: data0
            });
        }
    });



    //$.getJSON("http://localhost:7543/api/Values", null, function (data1) {
    //    ko.applyBindings({
    //        list1: data1
    //    });
    //});

</script>

